//
//  DailyCollectionViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/1/24.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "DailyCollectionViewCell.h"

@implementation DailyCollectionViewCell

- (void)dealloc{
    [_image1 release];
    [_image2 release];
    
    [_label1 release];
    [_label2 release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.image1 = [[UIImageView alloc] init];
        [self.contentView addSubview:_image1];
        [_image1 release];
        
        self.image2 = [[UIImageView alloc] init];
        [self.contentView addSubview: _image2];
        [_image2 release];
        
        self.label1 = [[UILabel alloc] init];
        [self.contentView addSubview:_label1];
        [_label1 release];
        
        
        self.label2 = [[UILabel alloc] init];
        [self.contentView addSubview:_label2];
        [_label2 release];
        
        
        
        
        
        
        
    }
    return self;
}

- (void)setModel:(Daily *)model{
    
    if (_model != model) {
        [_model release];
        _model = [model retain];
        
    }
    _image1.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, self.frame.size.height - 70);
    
    _label1.frame = CGRectMake(10, self.frame.size.height - 70 + 2, self.frame.size.width - 20, 40);
    _label1.font = [UIFont systemFontOfSize:11];
    _label1.numberOfLines = 2;
    
    _image2.frame = CGRectMake(10, self.frame.size.height - 70 + 2 + 35, 34, 30);
    _image2.layer.cornerRadius = 15;
    _image2.layer.masksToBounds = YES;
    
    _label2.frame = CGRectMake(55, self.frame.size.height - 70 + 2 + 40, 80, 20);
    _label2.font = [UIFont systemFontOfSize:10];
    
    
    [self setValues];
    
   
    
}


- (void)setValues{
    
    NSDictionary *dic = _model.data[0];
    
    [_image1 sd_setImageWithURL:[NSURL URLWithString:dic[@"index_cover"]] placeholderImage:[UIImage imageNamed:PLACE_HLODER]];
    
    _label1.text = dic[@"index_title"];
    
    [_image2 sd_setImageWithURL:[NSURL URLWithString:dic[@"user"][@"avatar_m"]] placeholderImage:[UIImage imageNamed:PLACE_HLODER]];
    
    _label2.text = dic[@"user"][@"name"];
    
}




@end
